<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Storage;

class ProjectResource extends JsonResource
{
    /**
     * @param Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'image' => Storage::disk('public')->url($this->image),
            'describe' => $this->describe,
            'date' => $this->date,
            'address' => getAreaName($this->province_id).getAreaName($this->city_id),//.getAreaName($this->district_id),
            'price' => $this->price,
            'content' => $this->content,
            'created_at' => $this->created_at->toDateString(),
        ];
    }
}
